<?php
class C_rendev extends CI_Controller{
	public function __construct(){
		parent::__construct();
	}	

	public function index()
	{
		$this->load->helper(array('form', 'url'));

		$this->load->library('form_validation');
			
		$this->form_validation->set_rules('libelle', 'Libelle', 'trim|required|xss_clean|alpha_dash');

		if(isset($_POST['date'])){
			$this->form_validation->set_rules('date', 'Date', 'trim|required|xss_clean');
		}
		if(isset($_POST['debut'])){
			$this->form_validation->set_rules('debut', 'Debut', 'trim|required|xss_clean');
		}	
		if(isset($_POST['fin'])){
			$this->form_validation->set_rules('fin', 'Fin', 'trim|required|xss_clean');}
		

		if ($this->form_validation->run() == FALSE)
		{
			$this->session->set_userdata('champ', true);	
			$this->load->view('v_creation');
		}
		else
		{
			if(!$this->session->userdata('champ')){
				/*$this->load->model('sondage');
				$this->sondage->creation($_POST);*/
				$this->load->view('v_succes');
			}
			else{
				$this->session->set_userdata('champ', false);	
				$this->load->view('v_creation');
			}
		}
	}
}
